package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.WdyTransfer;
import com.ruoyi.system.service.IWdyTransferService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资金划转 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-01-13
 */
@Controller
@RequestMapping("/system/wdyTransfer")
public class WdyTransferController extends BaseController
{
    private String prefix = "system/wdyTransfer";
	
	@Autowired
	private IWdyTransferService wdyTransferService;
	
	@RequiresPermissions("system:wdyTransfer:view")
	@GetMapping()
	public String wdyTransfer()
	{
	    return prefix + "/wdyTransfer";
	}
	
	/**
	 * 查询资金划转列表
	 */
	@RequiresPermissions("system:wdyTransfer:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyTransfer wdyTransfer)
	{
		startPage();
        List<WdyTransfer> list = wdyTransferService.selectWdyTransferList(wdyTransfer);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出资金划转列表
	 */
	@RequiresPermissions("system:wdyTransfer:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyTransfer wdyTransfer)
    {
    	List<WdyTransfer> list = wdyTransferService.selectWdyTransferList(wdyTransfer);
        ExcelUtil<WdyTransfer> util = new ExcelUtil<WdyTransfer>(WdyTransfer.class);
        return util.exportExcel(list, "wdyTransfer");
    }
	
	/**
	 * 新增资金划转
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存资金划转
	 */
	@RequiresPermissions("system:wdyTransfer:add")
	@Log(title = "资金划转", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyTransfer wdyTransfer)
	{		
		return toAjax(wdyTransferService.insertWdyTransfer(wdyTransfer));
	}

	/**
	 * 修改资金划转
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyTransfer wdyTransfer = wdyTransferService.selectWdyTransferById(id);
		mmap.put("wdyTransfer", wdyTransfer);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存资金划转
	 */
	@RequiresPermissions("system:wdyTransfer:edit")
	@Log(title = "资金划转", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyTransfer wdyTransfer)
	{		
		return toAjax(wdyTransferService.updateWdyTransfer(wdyTransfer));
	}
	
	/**
	 * 删除资金划转
	 */
	@RequiresPermissions("system:wdyTransfer:remove")
	@Log(title = "资金划转", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyTransferService.deleteWdyTransferByIds(ids));
	}
	
}
